﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SINGenerator
{
    class QuipGenerator
    {
        private List<string> quipsList;
        private Random rnd;

        public QuipGenerator()
        {
            rnd = new Random((int)System.DateTime.Now.Ticks);
            quipsList = new List<string>(Properties.Resources.quips.Split('\n'));
            quipsList = Shuffle(quipsList);
        }

        private List<T> Shuffle<T>(List<T> list)
        {
            List<T> randomizedList = list;
            Random rng = new Random();
            int n = randomizedList.Count;
            while (n > 1)
            {
                n--;
                int k = rng.Next(n + 1);
                T value = randomizedList[k];
                randomizedList[k] = randomizedList[n];
                randomizedList[n] = value;
            }
            return randomizedList;
        }

        public String GetRandomQuip()
        {
            if (quipsList.Count == 0)
                return "SIN Generator";

            int quipNo = System.DateTime.Now.Second;

            return quipsList[quipNo];
        }

    }
}
